package com.diaohw.platform.remote.file;

import com.diaohw.platform.common.constant.ServiceConstant;
import com.diaohw.platform.framework.openfeign.GlobalFeignResultConfig;
import com.diaohw.platform.remote.file.obj.bo.FileBo;
import com.diaohw.platform.remote.file.obj.query.FileQuery;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 文件请求
 */
@FeignClient(name = ServiceConstant.file, url = "${platform.openfeign.file:}", configuration = GlobalFeignResultConfig.class, contextId = "fileRemoteService")
public interface FileRemoteService {

    /**
     * 产看文件信息
     *
     * @param id 主键ID
     */
    @Operation(summary = "文件上传")
    @GetMapping("/file/{id}")
    FileBo info(@PathVariable("id") String id);

    /**
     * 文件上传
     *
     * @param bucket 根目录
     */
    @Operation(summary = "文件上传")
    @PostMapping("/file/{bucket}")
    FileBo upload(@PathVariable("bucket") String bucket, @RequestPart("file") MultipartFile file);

    /**
     * 按条件查询文件信息
     */
    @Operation(summary = "按条件查询文件信息")
    @GetMapping("/file")
    List<FileBo> list(@SpringQueryMap FileQuery bo);

}
